import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { DeliveryPlanFinalVO, DeliveryPlanFinalForm, DeliveryPlanFinalQuery, DeliveryPlanGanttDto } from '@/api/delivery/deliveryPlanFinal/types';

/**
 * 查询最终发货计划列表
 * @param query
 * @returns {*}
 */

export const listDeliveryPlanFinal = (query?: DeliveryPlanFinalQuery): AxiosPromise<DeliveryPlanGanttDto[]> => {
  return request({
    url: '/delivery/deliveryPlanFinal/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询最终发货计划详细
 * @param id
 */
export const getDeliveryPlanFinal = (id: string | number): AxiosPromise<DeliveryPlanFinalVO> => {
  return request({
    url: '/delivery/deliveryPlanFinal/' + id,
    method: 'get'
  });
};

/**
 * 新增最终发货计划
 * @param data
 */
export const addDeliveryPlanFinal = (data: DeliveryPlanFinalForm) => {
  return request({
    url: '/delivery/deliveryPlanFinal',
    method: 'post',
    data: data
  });
};

/**
 * 修改最终发货计划
 * @param data
 */
export const updateDeliveryPlanFinal = (data: DeliveryPlanFinalForm) => {
  return request({
    url: '/delivery/deliveryPlanFinal',
    method: 'put',
    data: data
  });
};

/**
 * 删除最终发货计划
 * @param id
 */
export const delDeliveryPlanFinal = (id: string | number | Array<string | number>) => {
  return request({
    url: '/delivery/deliveryPlanFinal/' + id,
    method: 'delete'
  });
};

/**
 * 计算最终发货计划
 */
export const calcDeliveryPlanFinal = () => {
  return request({
    url: '/delivery/deliveryPlanFinal/calcDeliveryPlanFinal',
    method: 'get'
  });
};
